// 中间件-函数接口
import cacheUkey from './middleware_fns/cache_ukey'
import setCarOrdersParams  from './middleware_fns/set_car_orders_params'
import reduceCarOrderUserAgentFlag from './middleware_fns/reduce_car_order_userAgentFlag'
import formatCarOrderValue from './middleware_fns/format_car_order_value'
import nullValue from './middleware_fns/res_null_value'
import mosaicCarStatus from'./middleware_fns/mosaic_car_status'
import carOrderFomatDate from './middleware_fns/car_order_fomat_date'
import resetCarOrderAPI from './middleware_fns/reset_car_order_API'
import syPlan from './middleware_fns/sy_plan'
import jgTypePre from './middleware_fns/jg_type_pre'
import buildCarModels from './middleware_fns/build_car_models'
import buildCarModelReqData from './middleware_fns/build_car_model_reqData'
import buildCarDangerReqData from './middleware_fns/build_car_danger_reqData'
import buildCarChargingReqData from './middleware_fns/build_car_charging_reqData'
import carChargingListRestructrue from './middleware_fns/car_charging_list_restructrue'
import carChargingUpdateRestructrue from './middleware_fns/car_charging_update_restructrue'
import buildCarOrderUpdate from './middleware_fns/build_car_order_update'
import carOrderRestructrue from './middleware_fns/car_order_restructrue'
import syPlanReverse from './middleware_fns/sy_plan_reverse'
import jgTypeReverse from './middleware_fns/jg_type_reverse'
import carTaxTypeConversion from './middleware_fns/car_tax_type_conversion'
import formatCarUpfileList from './middleware_fns/format_car_upfile_list'
import bulidCarStatusReqData from './middleware_fns/build_car_status_reqData'
import addNewOrderId from './middleware_fns/add_new_order_id'
import buildCarIndiaReqData from './middleware_fns/build_car_india_reqData'
import carChargingReverse from './middleware_fns/car_charging_reverse'
import carSingleReverse from'./middleware_fns/car_single_reverse'
import carUpdateSingleNumber from './middleware_fns/car_update_single_number'
import buildCarDeleteSingle from './middleware_fns/build_car_delete_single'
import buildCarRandomSingleReqData from './middleware_fns/build_car_random_single_reqData'
import buildCarUsableSingleReqData from './middleware_fns/build_car_usable_single_reqData'
import buildCarToIndiaReqData from './middleware_fns/build_car_toIndia_reqData'
import buildCarSingleStatusReqData from './middleware_fns/build_car_single_status_reqData'
import buildCarIntimidateReqDate from './middleware_fns/build_car_intimidate_reqData'
import organizationFomate from './middleware_fns/organization_fomat'
import buildMemberReqData from './middleware_fns/build_members_reqData'
import auditingDataFormt from './middleware_fns/auditing_data_formt'
import buildAuditingReqData  from './middleware_fns/build_auditing_reqData'
import buildAuditingChangeReqData from './middleware_fns/build_auditing_change_reqData'
import buildPowerFormat from './middleware_fns/build_power_fomat'
import userDataFomat from './middleware_fns/user_data_fomat'
import userPowerFomat from './middleware_fns/user_power_fomat'
import cacheUserInfo from'./middleware_fns/cache_userInfo'
import localCacheUserInfo from './middleware_fns/local_cache_userInfo'



interface reqItem {
    url:string,                   //请求地址
    method: string,               //请求方法 (只使用, post, get)
    reqBefore: commonInf.mdl[],   //请求前预处理
    resAfter: commonInf.mdl[],    //数据返回后预处理
}

interface reqConfig{
    [properName:string]:reqItem 
}

// 接口版本(未使用)
const edition = 'v1';

// 中间件配置
const rConfig:reqConfig = {

    // 登录
    [`post/token/id`]: {
        url: '/auth/signin',
        method: 'post',
        reqBefore: [],
        resAfter: [cacheUkey, userPowerFomat, cacheUserInfo, localCacheUserInfo]
    },

    

    //获取刷新后登录用户数据
    [`get/users/id?token=current`]: {
        url: '/app/user',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },
    
    // 注销
    [`delete/token/id`]:{
        url: '/app/user/signout',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    // 修改密码
    [`patch/users/id/password`]: {
        url: 'app/user/update-password',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },

    // 获取用户列表
    [`get/users`]: {
        url: '/app/users',
        method: 'get',
        reqBefore: [buildMemberReqData],
        resAfter: []
    },

    // 获取用户明细
    [`get/users/id`]: {
        url: '/app/user',
        method: 'get',
        reqBefore: [],
        resAfter: [userDataFomat, userPowerFomat]
    },
 
    // 新增用户
    [`post/users/id`]: {
        url: '/app/audits/new-account',
        method: 'post',
        reqBefore: [buildPowerFormat],
        resAfter: []
    },

    // 更新用户信息
    [`put/users/id`]: {
        url: '/app/audits/new-account',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },
  
    // 获取订单列表
    [`get/orders`]: {
        url:'/app/orders',
        method: 'get',
        reqBefore:[setCarOrdersParams, mosaicCarStatus],
        resAfter: [nullValue, reduceCarOrderUserAgentFlag, formatCarOrderValue]
    },  

    // 新建车险订单
    [`post/orders/id`]: {
        url: '/app/order',
        method: 'post',
        reqBefore: [],
        resAfter: [],
    },

    // 更新车险订单状态
    ['patch/order/id/status']: {
        url: '/app/order/status',
        method: 'post',
        reqBefore: [bulidCarStatusReqData],
        resAfter: []
    },

    // 获取车险订单详情
    ['get/orders/id']: {
        url: '/app/order',
        method: 'get',
        reqBefore: [],
        resAfter: [nullValue, resetCarOrderAPI, carTaxTypeConversion, carOrderFomatDate, syPlan, jgTypePre, carChargingListRestructrue,buildCarModels]
    },
    
    // 保存车险订单数据
    [`patch/orders/id`]: {
        url: '/app/order',
        method: 'post',
        reqBefore: [buildCarOrderUpdate,syPlanReverse,jgTypeReverse,carTaxTypeConversion,carOrderRestructrue],
        resAfter: [addNewOrderId],
    },

    // 获取车型列表
    [`get/car_modules`]: {
        url: 'service/ibsc/vehicles',
        method: 'get',
        reqBefore: [buildCarModelReqData],
        resAfter: []
    },

    // 更新 车型查询后数据 订单相关数据
    ['patch/order/id']:{
        url: '/app/order/update-vehicle-info',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },
    
    // 获取出险率
    ['get/danger_rate']:{
        url: '/service/ibsc/cxl',
        method: 'get',
        reqBefore: [buildCarDangerReqData],
        resAfter: []
    },

    // 更新出险率数据 （返回计费结果）
    [`patch/danger_rete`]: {
        url: '/service/mq/request',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    //获取车险计费结果
    [`get/bill/id`]: {
        url: '/service/mq/request',
        method: 'post',
        reqBefore: [buildCarChargingReqData],
        resAfter: [carChargingUpdateRestructrue]
    },

    // 公司列表
    [`get/companys`]: {
        url:'/app/sectors',
        method: 'get',
        reqBefore:[],
        resAfter: [organizationFomate]
    },

    // 获取部门列表(未使用)
    [`get/departments`]: {
        url: '/app/sectors',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    // 获取公司明细
    [`get/companys/id`]: {
        url: '/app/sector',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },
    
    // 获取部门明细
    [`get/departments/id`]: {
        url: '/app/sector',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    // 部门审核申请(新建)
    [`post/departments/id`]:{

        url: '/app/audits/new-sector',
        method: 'post',
        reqBefore: [],
        resAfter: []

    },
    
    // 获取审核列表
    [`get/auditings`]:{
        url: '/app/audits',
        method: 'get',
        reqBefore: [buildAuditingReqData],
        resAfter: [auditingDataFormt]
    },

    // 更新审核状态
    [`patch/auditings/id/status`]: {
        url: '/app/audits/checking',
        method: 'post',
        reqBefore: [buildAuditingChangeReqData],
        resAfter: []
    },

    // 获取权限列表
    [`get/users/id/power`]: {
        url: '/app/user/permissions',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    // 更新权限配置
    ['put/users/id/power']: {
        url: '/app/user/permissions',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },

    // 获取权限预设配置
    [`get/power_list`]: {
        url: '/service/data/permission-flags',
        method: 'get',
        reqBefore: [],
        resAfter: []
    },

    // 上传附件
    [`post/files/id`]: {
        url: '/app/order/attachments',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },

    // 获取附件列表
    [`get/files`]: {
        url: '/app/order/attachments',
        method: 'get',
        reqBefore: [],
        resAfter: [formatCarUpfileList]
    },

    // 删除附件
    [`delete/files/id`]: {
        url: '/app/order/attachment/delete',
        method: 'post',
        reqBefore: [],
        resAfter: []
    },

    // 获取集印单证列表
    ['get/printList']:{
        url: '/app/order/print-info',
        method: 'get',
        reqBefore: [buildCarIndiaReqData],
        resAfter: [carSingleReverse]
    },

    // 获取单证号
    ['get/single']:{
        url: '/app/order/create-sid',
        method: 'get',
        reqBefore: [buildCarRandomSingleReqData],
        resAfter: [carUpdateSingleNumber]
    },

    // 修改单证状态
    ['patch/single/id']: {
        url: '/app/order/set-single-state',
        method: 'get',
        reqBefore: [buildCarSingleStatusReqData],
        resAfter: []
    },

    // 删除单证
    ['delete/single/id']:{
        url: '/app/order/delete-single',
        method: 'get',
        reqBefore: [buildCarDeleteSingle],
        resAfter: []
    },

    // 获取可用单证
    ['get/usableSingles']:{
        url: '/app/order/get-singles',
        method: 'get',
        reqBefore: [buildCarUsableSingleReqData],
        resAfter: []
    },

    // 集印
    [`post/india/id`]: {
        url: 'http://localhost:9101/v1/add-print',
        method: 'post',
        reqBefore: [buildCarToIndiaReqData],
        resAfter: []
    },

    // 打单
    [`post/intimidate/id`]: {
        url:'http://localhost:9101/v1/print',
        method: 'post',
        reqBefore: [buildCarIntimidateReqDate],
        resAfter: []
    }
    
}


export default rConfig;